home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 February / Gamestar_81_2006-02_dvd.iso / Red Shark / Missions / Mission_5 / Mission.script < prev    next >
Text File  |  2002-01-31  |  6KB  |  227 lines

  1. //-------------------------------------------------------------------
  2. //
  3. //  This code is copyright 2001 by G5 Software.
  4. //  Any unauthorized usage, either in part or in whole of this code
  5. //  is strictly prohibited. Violators WILL be prosecuted to the
  6. //  maximum extent allowed by law.
  7. //
  8. //-------------------------------------------------------------------
  9.  
  10. class CClearVillageMission extends
  11.   CBaseMission, CClearVillageMissionObjectList, CClearVillageMission_Strings, CNavPointUser
  12. {
  13.   int GetAutoGeneratedUnitsQty()
  14.   {
  15.     return 6;
  16.   }
  17.  
  18.   void CClearVillageMission()
  19.   {
  20.     BaseMission_InitMission();
  21.  
  22.     BaseMission_UpdateLoadProgress();
  23.     CreateComponent("DebugCamera", "GameObject", "CDebugCamera");
  24.     SetComponentPosition("DebugCamera",
  25.       matrix(
  26.         1.0, 0.0, 0.0, 8000.0,
  27.         0.0, 1.0, 0.0, 8000.0,
  28.         0.0, 0.0, 1.0,  600.0,
  29.         0.0, 0.0, 0.0,    1.0
  30.       ));
  31.  
  32.     // CreateComponent(IDToRegister, ComponentID, ScriptName | FileName | "")
  33.     BaseMission_UpdateLoadProgress();
  34.     CreateComponent("Atmosphere", "Atmosphere", "CClearVillageMission_Atmosphere");
  35.  
  36.     BaseMission_UpdateLoadProgress();
  37.     CreateComponent("Sky", "SkyObject", "CClearVillageMission_Sky");
  38.  
  39.     BaseMission_UpdateLoadProgress();
  40.     CreateComponent("Terrain", "ProgressiveTerrainObject", "CClearVillageMission_Terrain");
  41.  
  42.     BaseMission_UpdateLoadProgress();
  43.     CreateComponent("Forest", "Forest", "CClearVillageMission_Forest");
  44.  
  45.     BaseMission_UpdateLoadProgress();
  46.     CreateComponent("AIController", "AIController", "CBaseAIController");
  47.  
  48.     BaseMission_CreateObjects();
  49.  
  50.     m_EnemyUnitsCount = 0;
  51.  
  52.     array m_Objects = GetObjectsIDs();
  53.  
  54.     for (int i = 0; i < m_Objects.size(); i = i + 1)
  55.     {
  56.       if (Core_IsStringStartsWith(m_Objects[i], "Nazi"))
  57.         m_EnemyUnitsCount = m_EnemyUnitsCount + 1;
  58.     }
  59.  
  60.     m_EnemyStructuresCount =
  61.       Core_CallFunction(
  62.         "Village_09",
  63.         "GetObjectsQuantity",
  64.         "CBaseGermanTent"
  65.       ) +
  66.       Core_CallFunction(
  67.         "Village_09",
  68.         "GetObjectsQuantity",
  69.         "CBaseGermanArmedDoubleHouse"
  70.       ) +
  71.       Core_CallFunction(
  72.         "Village_09",
  73.         "GetObjectsQuantity",
  74.         "CBaseGermanArmedSingleHouse"
  75.       ) +
  76.       Core_CallFunction(
  77.         "Village_09",
  78.         "GetObjectsQuantity",
  79.         "CBaseGermanGunTower"
  80.       );
  81.  
  82.  
  83.     m_FriendlyStructuresDestroyed = 0;
  84.   }
  85.  
  86.   int  m_EnemyUnitsCount;
  87.   int  m_EnemyStructuresCount;
  88.   int  m_FriendlyStructuresDestroyed;
  89.  
  90.   int  OBJECTIVE_CLEAN_UP                 = 0;
  91.   int  OBJECTIVE_KEEP_CIVILIAN_STRUCTURES = 1;
  92.  
  93.   array m_MissionObjectivesStatuses =
  94.           array(
  95.             str_ObjectiveInProgress,
  96.             str_ObjectiveInProgress
  97.           );
  98.  
  99.   array m_BonusMissionObjectivesStatuses =
  100.           array();
  101.  
  102.   //
  103.   //  'virtual' methods
  104.   //
  105.  
  106.   //
  107.   //  Mission statistics
  108.  
  109.   string GetMissionStatistics()
  110.   {
  111.     return str_StatisticsTitle;
  112.   }
  113.  
  114.   //
  115.   //  Mission navpoints
  116.  
  117.   array GetNavPoints()
  118.   {
  119.     array navpoints =
  120.       array(
  121.         GetNavPoint("NavPoint_Vasyuki"),
  122.         GetNavPoint("NavPoint_Marshevka"),
  123.         GetNavPoint("NavPoint_Gotovtsevo"),
  124.         GetNavPoint("NavPoint_Barinovo"),
  125.         GetNavPoint("NavPoint_Upyryovka"),
  126.         GetNavPoint("NavPoint_Korzhebino"),
  127.         GetNavPoint("NavPoint_Ovechkino"),
  128.         GetNavPoint("NavPoint_Gerasimovo"),
  129.         GetNavPoint("NavPoint_Ozerino")
  130. //        vector(7967.0, 8364.0, 600.0),
  131. //        vector(2017.0, 3896.0, 0.0),
  132. //        vector(3880.0, 12547.0, 600.0),
  133. //        vector(11864.0, 13886.0, 600.0),
  134. //        vector(11133.0, 11016.0, 600.0),
  135. //        vector(14715.0, 10547.0, 600.0),
  136. //        vector(13622.0, 4694.0, 600.0),
  137. //        vector(11463.0, 3015.0, 600.0),
  138. //        vector(7205.0, 3563.0, 600.0)
  139.       );
  140.     return navpoints;
  141.   }
  142.  
  143.   //
  144.   //  Mission map skin file
  145.  
  146.   string GetMapSkinFileName()
  147.   {
  148.     return "Missions/Mission_5/Map.skin";
  149.   }
  150.  
  151.   //
  152.   //  Mission specific event handlers
  153.   //
  154.  
  155.   //
  156.   //  Object destroyed event handler
  157.   //
  158.  
  159.   void OnGameObjectDestroyed(string _id)
  160.   {
  161.     BaseMission_OnGameObjectDestroyed(_id);
  162.  
  163.     // check for destroyed enemy building
  164.     if (Core_IsStringStartsWith(_id, "Village_09_CBaseGermanArmedSingleHouse") ||
  165.         Core_IsStringStartsWith(_id, "Village_09_CBaseGermanArmedDoubleHouse") ||
  166.         Core_IsStringStartsWith(_id, "Village_09_CBaseGermanTent") ||
  167.         Core_IsStringStartsWith(_id, "Village_09_CBaseGermanGunTower"))
  168.     {
  169.       m_EnemyStructuresCount = m_EnemyStructuresCount - 1;
  170.       Core_BroadcastEvent(
  171.         "OnDisplayMessage",
  172.         str_EnemyDestroyedMsg,
  173.         m_GoodNewsColor
  174.       );
  175.     }
  176.     else
  177.     if (Core_IsStringStartsWith(_id, "Village_09"))
  178.     {
  179.       // sheafs are not civil structures
  180.       if (Core_IsStringStartsWith(_id, "Village_09_CBaseSheaf") ||
  181.           Core_IsStringStartsWith(_id, "Village_09_CBaseBigSheaf"))
  182.       {
  183.         return;
  184.       }
  185.  
  186.       m_FriendlyStructuresDestroyed = m_FriendlyStructuresDestroyed + 1;
  187.       Core_BroadcastEvent(
  188.         "OnDisplayMessage",
  189.         str_CivilianDestroyedMsg,
  190.         m_BadNewsColor
  191.       );
  192.       Core_SendEventTo(
  193.         "Helicopter",
  194.         "ShowEventObject",
  195.         _id,                       //     - id of object to show
  196.         250.0                      //     - distance from camera to object
  197.         );
  198.  
  199.     }
  200.  
  201.     if (Core_IsStringStartsWith(_id, "Nazi"))
  202.     {
  203.       m_EnemyUnitsCount = m_EnemyUnitsCount - 1;
  204.     }
  205.  
  206.     if (m_FriendlyStructuresDestroyed == 4) // maximum 3 civilian buildings can be destroyed
  207.     {
  208.       BaseMission_FailObjective(OBJECTIVE_KEEP_CIVILIAN_STRUCTURES);
  209.       BaseMission_DelayedQuit();
  210.     }
  211.  
  212.     if (m_EnemyStructuresCount == 0 && m_EnemyUnitsCount == 0)
  213.     {
  214.       BaseMission_CompleteObjective(OBJECTIVE_KEEP_CIVILIAN_STRUCTURES);
  215.       BaseMission_CompleteObjective(OBJECTIVE_CLEAN_UP);
  216.     }
  217.   }
  218.  
  219.   void OnMissionLoaded()
  220.   {
  221.     Core_SendEventTo("Helicopter", "OnInitiallyEnableTargetScreen", false);
  222.  
  223.     // Start mission music playing
  224.     Core_SendEventTo(SOID_MusicController, "PlayMissionMusic", 5);
  225.   }
  226. }
  227.